package com.wm.blog_admin.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wm.blog_admin.controller.base.AdminBaseController;
import com.wm.blog_admin.query.TSysLogQuery;
import com.wm.blog_admin.service.TSysLogService;
import com.wm.blog_common.bean.QueryPage;
import com.wm.blog_common.domain.TSysLogDO;
import com.wm.blog_common.entity.TSysLog;
import com.wm.blog_common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 半卷流年
 * @since 2020-03-24
 */
@Slf4j
@RestController
@RequestMapping("/ai/tSysLog")
public class TSysLogController extends AdminBaseController {

    @Autowired
    private TSysLogService tSysLogService;

    /**
     * 根据ID查询
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Result<TSysLogDO> get(@PathVariable Long id) {
        return tSysLogService.selectById(id);
    }

    /**
     * 根据ID删除
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public Result<Boolean> delete(@PathVariable Long id){
        return tSysLogService.deleteById(id);
    }

    /**
     * 添加
     * @param tSysLog
     * @return
     */
    @PostMapping
    public Result insert(@RequestBody TSysLog tSysLog){
        return tSysLogService.insert(tSysLog);
    }

    /**
     * 修改
     * @param tSysLog
     * @return
     */
    @PutMapping
    public Result update(@RequestBody TSysLog tSysLog){
        return tSysLogService.update(tSysLog);
    }

    /**
     * 分页查询
     * @param current   查询页
     * @param size   每页显示条数
     * @param query 查询参数
     * @return
     */
    @GetMapping("/page")
    public Result<Page<TSysLogDO>> page(Integer current, Integer size, TSysLogQuery query){
        return tSysLogService.page(new QueryPage(current,size),query);
    }


}
